package cn.itcast.bos.service.system.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.itcast.bos.dao.system.PermissionRepository;
import cn.itcast.bos.domain.system.Permission;
import cn.itcast.bos.domain.system.User;
import cn.itcast.bos.service.system.PermissionService;
@Service
@Transactional
public class PermissionServiceImpl implements PermissionService {
	@Resource
	private PermissionRepository repository;
	@Override
	public List<Permission> findByUser(User user) {
		if (user.getUsername().equals("bao")) {
			return repository.findAll();
		}else{
			return repository.findByUser(user.getId());
		}
	}
	@Override
	public List<Permission> findAll() {
		return repository.findAll();
	}
	@Override
	public void save(Permission model) {
		repository.save(model);
	}

}
